package com.aaa.mrcai.service.impl;

import com.aaa.mrcai.mapper.ReceptionMapper;
import com.aaa.mrcai.pojo.entity.Notify;
import com.aaa.mrcai.pojo.entity.RState;
import com.aaa.mrcai.pojo.entity.Reception;
import com.aaa.mrcai.pojo.entity.Role;
import com.aaa.mrcai.pojo.vo.ReceptionStateVO;
import com.aaa.mrcai.query.SendQuery;
import com.aaa.mrcai.result.AjaxResult;
import com.aaa.mrcai.service.ReceptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author meowyf
 * @version 1.0
 * @Name Z_MJ
 * @date 2021/12/14 16:45:49
 */
@Service
public class ReceptionServiceImpl implements ReceptionService {
    @Autowired
    private ReceptionMapper receptionMapper;
    @Override
    public AjaxResult list(SendQuery sendQuery) {
        List<Reception> notify = receptionMapper.list(sendQuery);
        Long totalCount = receptionMapper.querySendTotalCount(sendQuery);

        HashMap<Object, Object> map = new HashMap<>();
        map.put("empListAll",notify);
        map.put("empNumber",totalCount);

        return AjaxResult.success(map);
    }

    @Override
    public AjaxResult listScontend(int id) {
        Notify notify = receptionMapper.listScontend(id);
        System.out.println("//////////////////"+notify);

        return AjaxResult.success(notify);
    }

    @Override
    public AjaxResult listRole() {
        List<Role> roles = receptionMapper.listRole();
        return AjaxResult.success(roles);
    }

    @Override
    public AjaxResult deleteReception(int id) {
        int i = receptionMapper.deleteReception(id);
        if (i>0){
            return AjaxResult.success();
        }
        return AjaxResult.defeated();
    }

    @Override
    public AjaxResult updateState(ReceptionStateVO receptionStateVO) {

            int i = receptionMapper.updateState(receptionStateVO);
            return AjaxResult.success();

    }

    @Override
    public AjaxResult deleteAll() {
        int i = receptionMapper.deleteAll();
        if (i>0){
            return AjaxResult.success();
        }
        return AjaxResult.defeated();
    }
}
